import java.util.*;
public class Main {
    /**
     * 前缀和
     * @param args
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt(),m=in.nextInt();
        long[] a=new long[n+1];
        long[] dp=new long[n+1];
        for(int i=1;i<=n;i++){
            a[i]=in.nextLong();
            dp[i]=dp[i-1]+a[i];
        }
        int cnt=0;
        while(cnt<m){
            int l=in.nextInt(),r=in.nextInt();
            long sum=0;
            sum=dp[r]-dp[l-1];
            System.out.println(sum);
            cnt++;
        }
    }

    /**
     * 点名
     * @param nums
     * @return
     */
    public static int takeAttendance(int[] nums) {
        int left=0,right=nums.length-1;
        while(left<right){
            int mid=left+(right-left)/2;
            if(nums[mid]==mid){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return left==nums[left]?left+1:left;
    }
}